<template>
  <div class="menuItem">
    <div v-if="menuStatus == 0">
      <div class="pbtn Mnormal" :class="[item.path == menuPath ? 'Mactive' : '']"
        v-for="(item, index) in menuItem.slice(0, 9)" @click="changeMenu(item, index)">
        <img :src="`/imgs/index/${item.meta.title}${item.path == menuPath ? '' : '-1'}.png`" alt="" />
        <p>{{ item.meta.title }}</p>
      </div>
    </div>
    <div v-if="menuStatus == 1">
      <div class="pbtn Mnormal" :class="[item.path == menuPath ? 'Mactive' : '']"
        v-for="(item, index) in menuItem.slice(9, 14)" @click="changeMenu(item, index + 9)">
        <img :src="`/imgs/index/${item.meta.title}${item.path == menuPath ? '' : '-1'}.png`" alt="" />
        <p>{{ item.meta.title }}</p>
      </div>
    </div>

    <!-- <div class="menuBot pbtn">
      <div class="menuBot_lft" :class="[menuStatus == 0 ? 'activeMbot' : '']" @click="menuStatus = 0"></div>
      <div class="menuBot_right" :class="[menuStatus == 1 ? 'activeMbot' : '']" @click="menuStatus = 1"></div>
    </div> -->
  </div>
</template>

<script setup>
import { ref, reactive, onMounted, toRef, computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useStore } from 'vuex'
const route = useRoute()
const router = useRouter()
//数据仓库库
const store = useStore()

const menuItem = route.matched[0].children
const menuPath = route.path
// const menuIndex = ref(0)

// const menuStatus = ref(0)
const menuStatus = toRef(store.state, 'menuStatusStore')
const menuIndex = toRef(store.state, 'menuIndex')

// menuStatus.value = computed(() => {
//   return menuIndex.value >  8 ? 1 : 0
// })

const changeMenu = (item, index) => {
  menuIndex.value = index
  console.log('menuIndex', menuIndex.value)
  router.push({ path: item.path })
}

// console.log(menuItem)
</script>

<style lang="scss" scoped>
.menuItem {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 740px;
}

.Mnormal {
  width: 60px;
  height: 54px;
  display: flex;
  margin: 25px 0;
  position: relative;
  align-items: center;
  justify-content: center;

  img {
    width: 35px;
    height: 35px;
    margin: 0 auto;
    // background-size: 100% 100%;
    background-repeat: no-repeat;
  }

  p {
    position: absolute;
    bottom: -20px;
    font-family: ShiShangZhongHeiJianTi;
    font-weight: 400;
    font-size: 15px;
    color: #7a9dd9;
  }
}

.Mnormal:hover {
  // background-image: url(/imgs/index/menuBg.png);
  background-size: 100% 100%;

  p {
    color: #63adfd;
  }
}

.Mactive {
  background-image: url(/imgs/index/menuBg.png);
  background-size: 100% 100%;

  p {
    color: #63adfd;
  }
}

.menuBot {
  position: absolute;
  bottom: -22px;
  display: flex;

  div {
    width: 17px;
    height: 4px;
    background: #d0dfff;
  }
}

.activeMbot {
  background: #4f9df4 !important;
}
</style>
